package com.stone.inventory.core.app.id;

import com.stone.inventory.core.domain.entity.InvTransaction;
import com.stone.inventory.sharding.helper.ShardingHelper;
import com.stone.inventory.sharding.id.ShardingIdInjector;

/**
 * 事务数据分片id注入器
 *
 * @author Mr_wenpan@163.com 2021/8/16 11:16 下午
 */
public class TransactionShardingIdInjector implements ShardingIdInjector<String, InvTransaction> {

    @Override
    public String getShardingData(InvTransaction injectionObject) {
        return injectionObject.getPosCode();
    }

    @Override
    public void injection(InvTransaction injectionObject, Long id) {
        injectionObject.setInvTransactionsId(id);
    }

    @Override
    public String logicTableName() {
        return ShardingHelper.getEntityLogicTable(InvTransaction.class);
    }
}